<template>
	<view class="detail">
		<view class="del">
			<view class="title">{{industryDetail.title}}</view>
			<!-- shijian -->
			<view class="time">
				<text class="sj">{{industryDetail.releaseTime}}</text>
				<view class="yan">
					<image src="../../static/first/see.png"></image>
					<view>{{industryDetail.browseNumber}}</view>
				</view>
			</view>
			<!-- wenzi -->
			<view class="wenzi" v-html="industryDetail.descript">

			</view>
			<!-- 承办单位 -->
			<!-- <view class="cbdw">
				<text>承办单位：</text>
				<text>公司注册</text>
			</view> -->
			<!-- 收藏分享 -->
			<view class="scfx">
				<view class="sc" @click="favorite(industryDetail.id)">
					<image :src="isKeep?'../../static/service/shoucangchoose.png':'../../static/service/shoucang.png'">
					</image>
					<text>收藏</text>
				</view>
				<view class="fx">
					<button class="btn" open-type="share">
						<image src="../../static/service/share.png"></image>
					</button>
					<text>分享</text>
				</view>
			</view>
		</view>
		<view class="empty"></view>
		<view class="hyrc">
			<view class="title_hy">
				<image src="../../static/first/meeting.png"></image>
				<text>会议日程</text>
			</view>
			<view class="box_table">
				<view class="td_tit">
					<text class="tr_time">时间</text>
					<text class="tr_name">会议日程</text>
				</view>
				<view class="td_tit" v-for="(item,index) in mettings">
					<text class="tr_time">{{item.meetingTime}}</text>
					<text class="tr_name">{{item.meetingName}}</text>
				</view>
			</view>
		</view>
		<!-- zhibo -->
		<view class="hyrc">
			<view class="title_hy">
				<image src="../../static/first/live.png"></image>
				<text>直播地址</text>
			</view>
			<view class="wz" v-for="(item,index) in liveBroadcast">
				<view class="http">{{item.address}}</view>
				<view class="img" @click="copy(item.address)">
					<image src="../../static/first/copy.png"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				mettings: [], //会议
				liveBroadcast: [],
				isKeep: false,
				industryDetail: {
					title: '',
					browseNumber: '',
					descript: '',
					imgUrl: '',
					releaseTime: '',
					id: ''
				}
			}
		},
		//发送给朋友
		onShareAppMessage(res) {},
		//分享到朋友圈
		onShareTimeline(res) {},
		onLoad(op) {
			let data = JSON.parse(decodeURIComponent(op.op))
			this.industryDetail.title = data.title
			this.industryDetail.browseNumber = data.browseNumber
			this.industryDetail.descript = data.descript
			this.industryDetail.imgUrl = data.imgUrl
			this.industryDetail.releaseTime = data.releaseTime
			this.industryDetail.id = data.id
			this.getMettings(data.id)
			this.getLiveBroadcast(data.id)
			this.industryFavoriteFlag(data.id)
		},
		methods: {
			//提示
			showToast(title) {
				uni.showToast({
					title: title,
					icon: 'none'
				})
			},
			//获取会议日程
			getMettings(industryId) {
				uni.request({
					url: this.$serverUrl + 'ftMeetings/getByIndustryId',
					data: {
						"industryId": industryId
					},
					success: (res) => {
						this.mettings = res.data
					},
					fail: (e) => {
						this.showToast('会议日程获取失败')
					}
				})
			},
			//获取直播地址
			getLiveBroadcast(industryId) {
				uni.request({
					url: this.$serverUrl + 'ftLiveBroadcast/getByIndustryId',
					data: {
						"industryId": industryId
					},
					success: (res) => {
						this.liveBroadcast = res.data
					},
					fail: (e) => {
						this.showToast('直播地址获取失败')
					}
				})
			},
			//粘贴复制
			copy(title) {
				uni.setClipboardData({
					data: title,
					success() {
						uni.showToast({
							title: '复制成功',
							icon: 'none'
						})
					}
				})
			},
			//判断是否收藏过
			industryFavoriteFlag(industryDetailsId) {
				let userInfo = uni.getStorageSync('userInfo')
				uni.request({
					url: this.$serverUrl + 'ftIndustryDetailsFavorite/industryFavoriteFlag',
					data: {
						"userId": userInfo.id,
						"industryDetailsId": industryDetailsId
					},
					method: 'POST',
					success: (res) => {
						if (res.data > 0) {
							this.isKeep = true
						} else {
							this.isKeep = false
						}
					}
				})
			},
			//收藏
			favorite(id) {
				let userInfo = uni.getStorageSync('userInfo')
				if (this.isKeep == true) {
					//取消收藏
					uni.request({
						url: this.$serverUrl + 'ftIndustryDetailsFavorite/cacelIndustryFavorite',
						data: {
							"userId": userInfo.id,
							"industryDetailsId": id
						},
						method: 'POST',
						success: (res) => {
							this.isKeep = false
							this.showToast('取消成功')
						}
					})
				} else {
					//收藏
					uni.request({
						url: this.$serverUrl + 'ftIndustryDetailsFavorite/addIndustryFavorite',
						data: {
							"userId": userInfo.id,
							"industryDetailsId": id
						},
						method: 'POST',
						success: (res) => {
							this.isKeep = true
							this.showToast('收藏成功')
						}
					})
				}
			}
		}
	}
</script>

<style>
	.btn {
		padding: 0;
		margin: 0;
		color: #222222;
		background-color: #FFFFFF;
		font-size: 28rpx;
		line-height: 40rpx;
		margin-top: 10rpx;
	}

	.btn::after {
		border: none;
	}

	.yan {
		display: flex;
	}

	.del {
		margin: 52upx 36upx 0;
	}

	.title {
		font-size: 40upx;
		color: #333333;
	}

	/* time */
	.time {
		display: flex;
		justify-content: space-between;
		margin: 36upx 0 56upx;
		font-size: 24upx;
	}

	.sj {
		color: #999999;
	}

	.time image {
		width: 36upx;
		height: 36upx;
	}

	/* 文字 */
	.wenzi {
		margin-bottom: 52upx;

	}

	.cbdw {
		font-size: 24upx;
		color: #666666;
	}

	.sc {
		display: flex;
		align-items: center;
	}

	.sc image {
		width: 52upx;
		height: 52upx;
	}

	.sc text {
		font-size: 26upx;
		color: #666666;
	}

	.scfx {
		margin: 52upx 0;
		display: flex;
		font-size: 24upx;
	}

	.fx {
		display: flex;
		align-items: center;
		margin-left: 40upx;
	}

	.fx image {
		width: 52upx;
		height: 52upx;
	}

	.fx text {
		font-size: 26upx;
		color: #666666;
	}

	.empty {
		height: 10upx;
		background-color: #F5F5F5;
	}

	.hyrc {
		margin: 52upx 36upx 88upx;
	}

	/*  */
	.title_hy image {
		width: 40upx;
		height: 40upx;

	}

	.title_hy text {
		margin-left: 20upx;
		font-weight: bold;
	}

	.title_hy {
		color: #333333;
		font-size: 34upx;
		/* margin-bottom: 20upx; */
	}

	.box_table {
		font-size: 24upx;
		margin-top: 20upx;
	}

	.td_tit {
		background-color: #F5F5F5;
		height: 62upx;
		line-height: 62upx;
	}

	.tr_time {
		margin-left: 26upx;
		width: 30%;
		display: inline-block;
	}

	.tr_name {
		/* margin-left: 184upx; */
	}

	.http {
		margin-top: 20upx;
		width: 90%;
		height: 70upx;
		display: flex;
		flex-wrap: wrap;
		align-items: center;
	}

	.wz {
		font-size: 24upx;
		display: flex;
		align-items: center;
	}

	.img image {
		width: 34upx;
		height: 40upx;
		display: flex;
		align-items: center;
		justify-content: center;
		margin-left: 30upx;
	}

	.img {
		width: 10%;
		display: flex;
		align-items: center;
		justify-content: center;
		vertical-align: middle;
		height: 70upx;
	}
</style>
